<html>
	<head>
		<link rel="stylesheet" type="text/css" href="stylize2.css">
	</head>
	
	<body>
		<div id = firstBar>
			<img src = "Logopl.png">
		</div>
		
		<div id = menu>
			<ul>
				<li><a href = "">Home</a></li>
				<li><a href = "">Fuses</a></li>
				<li><a href = "">MyBoard</a></li>
			</ul>
		</div>
		
		<div id = secondBar>
		</div>	
		
		<div id = "fuseBody">
			<?php
				$categoryId = $_GET ["categoryId"];
				$con = mysql_connect("localhost","root","");
				if (!$con)
				{
					die('Could not connect: ' . mysql_error());
				}

				$currentLetter = '';
				$newLetter = '';
				
				mysql_select_db("rgfusion", $con);

				$result = mysql_query("SELECT * FROM companies WHERE companycategory = " . $categoryId . " ORDER BY companyName");

				$indexText = "<div>";
				$mainText = "";
				
				while($row = mysql_fetch_array($result))
				{
					$companyName = $row["companyName"];
					$newLetter = $companyName[0];
				
					if ($newLetter != $currentLetter)
					{
						if ($currentLetter != '')
						{
							$mainText .= "</ul></div>";
						}

						$mainText .= '<div class = "clothesList">
							<a name="' . $newLetter . '"><h1>' . $newLetter . '</h1></a>
							<ul>';
						
						$currentLetter = $newLetter;
						
						$indexText .= '<a href = "#' . $currentLetter . '">' . $currentLetter . '</a>';
					}
					
					$mainText .= '<li><a href = "">' . htmlentities($row["companyName"]) . '</a></li>';
				}

				$indexText .= "</div>";
				
				if ($currentLetter != '')
				{
					$mainText .= "</ul></div>";
				}

				echo $indexText;
				echo $mainText;
				
				mysql_close($con);
			?>
				
			<!--<div class = "clothesList">
				<h1>A</h1>
				<ul>
					<li><a href = "">Abercrombie &amp; Fitch</a></li>
					<li><a href = "">Adidas<sup>&reg;</sup></a><li>
					<li><a href = "">Aeropostale</a></li>
					<li><a href = "">American Eagle</a></li>
					<li><a href = "">Armani Exchange</a></li>
					<li><a href = "">Asics<sub>&reg;</sub></a></li>
					<li><a href = "">Athleta</a></li>
				</ul>
			</div>
			
			<div class = "clothesList">
				<h1>B</h1>
				<ul>
					<li><a href = "">Banana Republic</a></li>
					<li><a href = "">Bloomingdale's</a></li>
					<li><a href = "">Bon-Ton&reg;</a></li>
					<li><a href = "">Burlington Coat Factory</a></li>
				</ul>
			</div>
			
			<div class = "clothesList">
				<h1>C</h1>
				<ul>
					<li><a href = "">Calvin Klein</a></li>
					<li><a href = "">Columbia</a></li>
					<li><a href = "">Converse</a></li>
				</ul>
			</div>
			
			<div class = "clothesList">
				<h1>D</h1>
					<ul>
						<li><a href = "">dELiA's</a></li>
						<li><a href = "">DKNY</a></li>	
					</ul>
			</div>
			
			<div class = "clothesList">
				<h1>E</h1>
					<ul>
						<li><a href = "">Eddie Bauer<sup>&reg;</sup></a></li>
						<li><a href = "">Express</a></li>
					</ul>
			</div>
			
			<div class = "clothesList">
				<h1>F</h1>
					<ul>
						<li><a href = "">Forever21<sup>&reg;</sup></a></li>
					</ul>
			</div>
			
			<div class = "clothesList">
				<h1>G</h1>
					<ul>
						<li><a href = "">Gap</a></li>
						<li><a href = "">Guess<sup>&reg;</sup></a></li>
					</ul>
			</div>
			
			<div class = "clothesList">
				<h1>J</h1>
					<ul>
						<li><a href = "">JCPenney<sub>&reg;</sub></a></li>
					</ul>
			</div>
			
			<div class = "clothesList">
				<h1>K</h1>
					<ul>
						<li><a href = "">Kohl's</a></li>
						<li><a href = "">K-Swiss&reg;</a></li>
					</ul>
			</div>
			
			<div class = "clothesList">
				<h1>L</h1>
					<ul>
						<li><a href = "">Lacoste</a></li>
						<li><a href = "">Lee<sup>&reg;</sup></a></li>
						<li><a href = "">L.L. Bean</a></li>
						<li><a href = "">Lord & Taylor</a></li>
					</ul>
			</div>
			
			<div class = "clothesList">
				<h1>M</h1>
					<ul>
						<li><a href = "">Macy's</a></li>
					</ul>
			</div>
			
			<div class = "clothesList">
				<h1>N</h1>
					<ul>
						<li><a href = "">Neiman Marcus</a></li>
						<li><a href = "">New Balance/NB<sup>&reg;</sup></a></li>
						<li><a href = "">Nike<sup>&reg;</sup></a></li>
						<li><a href = "">Nordstrom</a></li>
					</ul>
			</div>
			
			<div class = "clothesList">
				<h1>O</h1>
					<ul>
						<li><a href = "">Old Navy</a></li>
					</ul>
			</div>
			
			<div class = "clothesList">
				<h1>P</h1>
					<ul>
						<li><a href = "">PUMA<sub>&reg;</sub></a></li>
					</ul>
			</div>
			
			<div class = "clothesList">
				<h1>R</h1>
					<ul>
						<li><a href = "">Ralph Lauren</a></li>
						<li><a href = "">Reebok</a></li>
					</ul>
			</div>
			
			<div class = "clothesList">
				<h1>S</h1>
					<ul>
						<li><a href = "">Sak's Fifth Avenue</a></li>
						<li><a href = "">Sears</a></li>
						<li><a href = "">Skecher's</a></li>
					</ul>
			</div>
			
			<div class = "clothesList">
				<h1>T</h1>
					<ul>
						<li><a href = "">The North Face&reg;</a></li>
						<li><a href = "">Timberland&reg;</a></li>
					</ul>
			</div>
			
			<div class = "clothesList">
				<h1>U</h1>
					<ul>
						<li><a href = "">UGG&reg;</a></li>
						<li><a href = "">Urban Oufitters</a></li>
					</ul>
			</div>
			
			<div class = "clothesList">
				<h1>W</h1>
					<ul>
						<li><a href = "">Wet Seal<sub>&reg;</sub></a></li>
					</ul>
			</div>-->
		</div>
	</body>
</html>